package cn.com.lyj6851.modules.activity.controller;

import cn.com.lyj6851.logging.aop.AopLog;
import cn.com.lyj6851.modules.activity.service.YdyStoreCouponIssueUserService;
import cn.com.lyj6851.modules.activity.service.dto.YdyStoreCouponIssueUserQueryCriteria;
import cn.com.lyj6851.modules.aop.ForbidSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
*
*/
@Api(tags = "商城:优惠券前台用户领取记录管理")
@RestController
@RequestMapping("api")
public class StoreCouponIssueUserController {

    private final YdyStoreCouponIssueUserService yxStoreCouponIssueUserService;

    public StoreCouponIssueUserController(YdyStoreCouponIssueUserService yxStoreCouponIssueUserService) {
        this.yxStoreCouponIssueUserService = yxStoreCouponIssueUserService;
    }

    @AopLog("查询")
    @ApiOperation(value = "查询")
    @GetMapping(value = "/ydyStoreCouponIssueUser")
    @PreAuthorize("hasAnyRole('admin','STORECOUPONISSUEUSER_ALL','STORECOUPONISSUEUSER_SELECT')")
    public ResponseEntity getYdyStoreCouponIssueUsers(YdyStoreCouponIssueUserQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(yxStoreCouponIssueUserService.queryAll(criteria,pageable),HttpStatus.OK);
    }


    @ForbidSubmit
    @AopLog("删除")
    @ApiOperation(value = "删除")
    @DeleteMapping(value = "/ydyStoreCouponIssueUser/{id}")
    @PreAuthorize("hasAnyRole('admin','STORECOUPONISSUEUSER_ALL','STORECOUPONISSUEUSER_DELETE')")
    public ResponseEntity delete(@PathVariable Integer id){
        yxStoreCouponIssueUserService.removeById(id);
        return new ResponseEntity(HttpStatus.OK);
    }
}
